import {readFile} from "fs/promises";
import chalk from "chalk";
import {glob} from 'glob';
import FriSat from "./main";

console.clear();
console.log(chalk.bold('c', "YO! HAVE A NICE WEEKEND! GREETINGS FROM THU-FRI-SAT."))
console.log(chalk.bold('c', "===================================================="))

let path;
switch (process.argv[2]) {
  case 'regtest': path = 'regtest/*.cnf'; break;
  case 'bunchmark': path = 'bunchmark/*.cnf'; break;
  default: path = process.argv[2];
}

for (let filePath of await glob(path)) {
  console.log('c', chalk.cyan.bold(filePath))
  let text = await readFile(filePath, {encoding: 'utf8'});
  let comm = text.split('\n').filter(l => l[0] === 'c').join('\n')
  console.log(chalk.cyan(comm))
  const sat = FriSat();
  sat.parse(text);
  console.log(Object.entries(sat.solve()).map(([k, v]) => `${k} ${v}`).join('\n'));
}

